﻿using System;
using System.ComponentModel;

namespace QuizzMe.Model
{
    /// <summary>
    /// Represent a "rank line" composed by a user, and some other data. This is used for display only.
    /// </summary>
    public class VRank : INotifyPropertyChanged
    {
        private string _name;

        /// <summary>
        /// User facebookId
        /// </summary>
        public string FbId
        {
            get; set;
        }

        /// <summary>
        /// User score
        /// </summary>
        public int Score
        {
            get; set;
        }

        /// <summary>
        /// User rank
        /// </summary>
        public int Rank
        {
            get; set;
        }

        /// <summary>
        /// User name
        /// </summary>
        public string Name
        {
            get { return _name; }
            set
            {
                if (_name != value)
                {
                    _name = value;
                    FirePropertyChanged("Name");
                }
            }
        }
        

        public VRank(string fbUid, int score)
        {
            FbId = fbUid;
            Name = string.Empty;
            Score = score;
        }
        
        public override string ToString()
        {
            return String.Format("{0}: {1}pts", Name, Score);
        }

        public void FirePropertyChanged(string property)
        {
            if(PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(property));
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}